package cc.inik.smarttraffic;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.nle.mylibrary.enums.led.PlayType;
import com.nle.mylibrary.enums.led.ShowSpeed;
import com.nle.mylibrary.forUse.led.LedScreen;
import com.nle.mylibrary.transfer.DataBusFactory;

public class MainActivity extends AppCompatActivity {

    private EditText editText;
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bindView();
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LedScreen ledScreen = new LedScreen(DataBusFactory.newSocketDataBus("172.16.8.200",6002));
                try {
                    ledScreen.switchLed(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    Log.i("type_",PlayType.DOWN_OVER.toString());
                    ledScreen.sendTxt(editText.getText().toString(), PlayType.DOWN_OVER, ShowSpeed.SPEED4,2,90);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    private void bindView(){
        editText = findViewById(R.id.input_text);
        button = findViewById(R.id.send_btn);
    }
}